package com.sangcomz.fishbun.util;

import com.sangcomz.fishbun.ResourceTable;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.StackLayout;
import ohos.agp.components.Text;
import ohos.agp.window.dialog.ToastDialog;
import ohos.app.Context;

public class ToastUtil {

    public static void showToast(Context context, String msg) {

        StackLayout toastLayout = (StackLayout) LayoutScatter.getInstance(context)
                .parse(ResourceTable.Layout_layout_toast, null, false);

        Text text = (Text) toastLayout.findComponentById(ResourceTable.Id_msg_toast);
        text.setText(msg);

        new ToastDialog(context)
                .setComponent(toastLayout)
                .setSize(StackLayout.LayoutConfig.MATCH_CONTENT, StackLayout.LayoutConfig.MATCH_CONTENT)
                .show();
    }

}
